home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Form1"
- ClientHeight = 3420
- ClientLeft = 2490
- ClientTop = 3285
- ClientWidth = 6540
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 3825
- Left = 2430
- LinkTopic = "Form1"
- ScaleHeight = 3420
- ScaleWidth = 6540
- Top = 2940
- Width = 6660
- Begin VB.CommandButton Command4
- Caption = "Help File"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 5175
- TabIndex = 17
- Top = 1080
- Width = 1200
- End
- Begin VB.TextBox Text3
- Appearance = 0 'Flat
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 1455
- TabIndex = 14
- Text = """This is text"", to parse"
- Top = 2835
- Width = 3285
- End
- Begin VB.CommandButton Command3
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "Parse Immediate"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 360
- Left = 4875
- TabIndex = 13
- Top = 2805
- Width = 1530
- End
- Begin VB.Frame Frame2
- Caption = "Quotes"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 960
- Left = 105
- TabIndex = 8
- Top = 915
- Width = 1770
- Begin VB.CheckBox Check1
- Caption = "Pair Quotes"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 315
- Left = 135
- TabIndex = 10
- Top = 255
- Value = 1 'Checked
- Width = 1335
- End
- Begin VB.CheckBox Check2
- Caption = "Trim Quotes"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 345
- Left = 135
- TabIndex = 9
- Top = 540
- Value = 1 'Checked
- Width = 1380
- End
- End
- Begin VB.Frame Frame1
- Caption = "Case"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 1260
- Left = 2250
- TabIndex = 4
- Top = 900
- Width = 1650
- Begin VB.OptionButton Option1
- Caption = "Lower"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 315
- Index = 2
- Left = 75
- TabIndex = 7
- Top = 855
- Width = 1095
- End
- Begin VB.OptionButton Option1
- Caption = "Upper"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 315
- Index = 1
- Left = 75
- TabIndex = 6
- Top = 555
- Width = 1095
- End
- Begin VB.OptionButton Option1
- Caption = "Don't Convert"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 315
- Index = 0
- Left = 75
- TabIndex = 5
- Top = 255
- Value = -1 'True
- Width = 1395
- End
- End
- Begin VB.TextBox Text2
- Appearance = 0 'Flat
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 300
- Left = 1065
- TabIndex = 3
- Text = "C:\NParse32\readme.txt"
- Top = 135
- Width = 3255
- End
- Begin VB.TextBox Text1
- Appearance = 0 'Flat
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 1065
- TabIndex = 2
- Text = ","
- Top = 480
- Width = 945
- End
- Begin VB.CommandButton Command2
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "Stop Parse"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 5175
- TabIndex = 1
- Top = 600
- Width = 1200
- End
- Begin VB.CommandButton Command1
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "Parse"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 5175
- TabIndex = 0
- Top = 135
- Width = 1200
- End
- Begin NPARSE32Lib.NParse32 NParse321
- Left = 4260
- Top = 1140
- _Version = 65536
- _ExtentX = 926
- _ExtentY = 1005
- _StockProps = 0
- End
- Begin VB.Label Label4
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Click ""Parse Immediate"" to parse the text in the ""Immediate Text"" box"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 330
- Left = 60
- TabIndex = 16
- Top = 2475
- Width = 6075
- End
- Begin VB.Line Line1
- X1 = 30
- X2 = 6510
- Y1 = 2355
- Y2 = 2355
- End
- Begin VB.Label Label3
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Immediate Text:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 300
- Left = 75
- TabIndex = 15
- Top = 2880
- Width = 1275
- End
- Begin VB.Label Label2
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Delimiter:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 300
- Left = 75
- TabIndex = 12
- Top = 495
- Width = 915
- End
- Begin VB.Label Label1
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Filename:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 300
- Left = 75
- TabIndex = 11
- Top = 165
- Width = 1020
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- '--------------------------
- 'The following is a list of constants used by NParse32. We suggest cutting
- 'and pasting the constants into either a module or form declaration area in your
- 'application instead of hardcoding the values. It makes for more readable and
- 'maintainable code.
- '--------------------------
- 'NErr Constants
- Const NOERRORS = 0 '//no error for err property
- Const FILEOPENFAILURE = 1 '//failed to open the input file
- Const FILENOTOPENFAILURE = 2 '//attempting to parse a file that is not open
- Const FILEALREADYOPENFAILURE = 3 '//attempting open a file when already opened
- Const NONREENTRANT = 4 '// changed filename at the wrong time
- Const INVALIDFIELDINDEX = 5 '//attempted to get a field that doesn't exist in record
- Const INVALIDPOSITIONOFFSET = 6 '//attempted to set file pointer outside of file range
- Const MEMORYALLOCATIONERROR = 7 '//could not allocate temporary memory
- 'Case Constants
- Const DONTCONVERTCASE = 0 '//don
- t convert input to either upper or lower case
- Const CONVERTTOUPPERCASE = 1 '//convert inputs to uppercase
- Const CONVERTTOLOWERCASE = 2 '//convert inputs to lower case
- 'Proc Constants
- Const STARTPARSE = 1 '//init parser, fire start event
- Const STOPPARSE = 2 '//stop parsing, fire end event
- 'Misc Constants
- Const NOPROCESS = -1 '//default - proc property is not in use yet
- 'the following is for shelling out to another application
- Const SW_SHOWNORMAL = 1
- Private Declare Function ShellExecute Lib _
- "shell32.dll" Alias "ShellExecuteA" _
- (ByVal hwnd As Long, _
- ByVal lpOperation As String, _
- ByVal lpFile As String, _
- ByVal lpParameters As String, _
- ByVal lpDirectory As String, _
- ByVal nShowCmd As Long) As Long
- Private Sub Command1_Click()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- 'This routine is used to start the parsing process on a file.
- 'first, disable the Immediate parse button so that user cannot
- 'attempt to do an immediate parse while a potentially long file
- 'parse is in progress.
- Command3.Enabled = False 'disable the immediate parse for the duration
- Form2.Show 'make sure output form is open
- 'next, read in the options that have been selected
- NParse321.NPFilename = Text2.Text 'get the filename
- NParse321.Delim = Text1.Text 'get the delimiters
- NParse321.PairQuotes = Check1.Value 'do we want to pair quotes?
- NParse321.TrimQuotes = Check2.Value 'do we want to trim off quotes?
- If Option1(1).Value = True Then 'convert case as requested
- NParse321.Case = CONVERTTOUPPERCASE
- If Option1(2).Value = True Then
- NParse321.Case = CONVERTTOLOWERCASE
- Else
- NParse321.Case = DONTCONVERTCASE
- End If
- End If
- 'OK, Now let'er rip!
- NParse321.Proc = STARTPARSE 'tell it to start
- End Sub
- Private Sub Command2_Click()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- 'This code is used to halt a parse that is in progress.
- NParse321.Proc = STOPPARSE 'halt the parse
- End Sub
- Private Sub Command3_Click()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- 'This routine is used parse a single text string.
- Dim lMyNumberOfFields As Long
- Dim I As Long
- Dim sMyField As String
- 'first, disable the Parse button so that user cannot
- 'attempt to parse a file while an immediate parse is running
- Command1.Enabled = False 'disable "Parse"
- Command2.Enabled = False 'disable "Stop"
- 'next, read in the options that have been selected
- NParse321.Delim = Text1.Text 'get the delimiters
- NParse321.PairQuotes = Check1.Value 'do we want to pair quotes?
- NParse321.TrimQuotes = Check2.Value 'do we want to trim off quotes?
- If Option1(1).Value = True Then 'convert case as requested
- NParse321.Case = CONVERTTOUPPERCASE
- If Option1(2).Value = True Then
- NParse321.Case = CONVERTTOLOWERCASE
- Else
- NParse321.Case = DONTCONVERTCASE
- End If
- End If
- Form2.Show 'make sure form 2 is displayed
- Form2.Text1.Text = "" 'clear out any existing text in the output box
- 'OK, Set the text to make parser parse it.
- NParse321.NPRecord = Text3.Text ' give the parse control some text
- 'Determine how many fields there were in the current record
- lMyNumberOfFields = NParse321.NumFlds()
-
- 'now start displaying output
- Form2.Text1.Text = Form2.Text1.Text & "Immediate String Parse" & Chr$(13) & Chr$(10)
- 'print out the number of fields in this record
- Form2.Text1.Text = Form2.Text1.Text & "NumFields: " & CStr(lMyNumberOfFields) & Chr$(13) & Chr$(10)
- 'output the whole record
- Form2.Text1.Text = Form2.Text1.Text & "NPRecord: " & NParse321.NPRecord & Chr$(13) & Chr$(10)
- 'Next loop through each field and output the values
- For I = 0 To (lMyNumberOfFields - 1) 'NumFlds is ones-based
- sMyField = NParse321.Fld(I) 'get the field
- Form2.Text1.Text = Form2.Text1.Text & "FN: " & CStr(I) & " Value: " & sMyField & Chr$(13) & Chr$(10)
- Next I
- DoEvents 'allow the display to update
- Command1.Enabled = True 'enable "Parse"
- Command2.Enabled = True 'enable "Stop"
- End Sub
- Private Sub Command4_Click()
- Dim iRet As Long
- Dim vbNullString As String
- Dim SrcDirectory As String
- SrcDirectory = App.Path & "\" & "Nphlp1.hlp"
- iRet = ShellExecute(Me.hwnd, _
- vbNullString, _
- SrcDirectory, _
- vbNullString, _
- "c:\", _
- SW_SHOWNORMAL)
-
- If iRet < 33 Then
- MsgBox "Unable To Open Help File"
- End If
- End Sub
- Private Sub Form_Load()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- Form2.Show 'load the output form
- DoEvents
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- Unload Form2
- End Sub
- Private Sub NParse321_NPErr()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- MsgBox CStr(NParse321.NErr)
- End Sub
- Private Sub NParse321_Parse()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- 'This event is fired when NParse32 has finished parsing a
- 'record. You should put the code that retrieves the parsed
- 'data here.
- Dim lMyNumberOfFields As Long
- Dim I As Long
- Dim sMyField As String
- Dim lMyRecordNumber As Long
- lMyRecordNumber = NParse321.RecNum 'get the record number
-
- If ((lMyRecordNumber Mod 5) = 0) Then 'every so often, clean up the display so the text string doesn't get too long
- Form2.Text1.Text = ""
- End If
- 'Determine how many fields there were in the current record
- lMyNumberOfFields = NParse321.NumFlds()
-
- 'Now Print out the record number
- Form2.Text1.Text = Form2.Text1.Text & "RecNum: " & CStr(lMyRecordNumber) & Chr$(13) & Chr$(10)
-
- 'now print out the byte offset
- Form2.Text1.Text = Form2.Text1.Text & "Position: " & CStr(NParse321.Position) & Chr$(13) & Chr$(10)
- 'print out the number of fields in this record
- Form2.Text1.Text = Form2.Text1.Text & "NumFields: " & CStr(lMyNumberOfFields) & Chr$(13) & Chr$(10)
- 'output the whole record
- Form2.Text1.Text = Form2.Text1.Text & "NPRecord: " & NParse321.NPRecord & Chr$(13) & Chr$(10)
- 'Next loop through each field and output the values
- For I = 0 To (lMyNumberOfFields - 1) 'NumFlds is ones-based
- sMyField = NParse321.Fld(I) 'get the field
- Form2.Text1.Text = Form2.Text1.Text & "FN: " & CStr(I) & " Value: " & sMyField & Chr$(13) & Chr$(10)
- Next I
- 'add a blank line for separation
- Form2.Text1.Text = Form2.Text1.Text & Chr$(13) & Chr$(10)
- DoEvents
- End Sub
- Private Sub NParse321_Start()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- 'This event is fired when the NParse32 control is first
- 'told to go parse a file. This is where you should put any
- 'initialization stuff (like counters, etc.)
- 'Put initialization code here
- Form2.Text1.Text = "" 'clear the output box.
- 'first, disable the Immediate parse button so that user cannot
- 'attempt to do an immediate parse while a potentially long file
- 'parse is in progress.
- Command1.Enabled = False 'disable the file parse for the duration
- Command3.Enabled = False 'disable the immediate parse for the duration
- End Sub
- Private Sub NParse321_Stop()
- '-----------------------------------------------------------------------------------------
- ' This sample code may be copied for use in your applications,
- ' however Nanoware, Inc. makes no warranty as to the completeness
- ' or fitness for a particular purpose that this code provides, it
- 'is merely a simple learning tool.
- '-----------------------------------------------------------------------------------------
- 'This event is called when the parse is complete, either
- 'because user application stopped it or we have reached the
- 'end of the input file.
- 'Put your cleanup code here.
- Command3.Enabled = True 'enable Immediate
- Command1.Enabled = True 'enable "Parse"
- Command2.Enabled = True 'enable "Stop"
- 'MsgBox "Stop fired"
- End Sub
-